package com.ourteam.workspace.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.workspace.dao.WorkspaceFileTypeConfigDAOQueryBean;
import com.ourteam.workspace.domain.WorkspaceFileTypeConfigBean;

public class WorkspaceFileTypeConfigSearchModel extends AbstractSearchModel<WorkspaceFileTypeConfigDAOQueryBean> {

	private String fileTypeName;

	private String fileExtension;

	@Override
	public String getMappedDAOField(String aProperty) {
		return WorkspaceFileTypeConfigBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(WorkspaceFileTypeConfigDAOQueryBean queryBean) throws Exception {

		WorkspaceFileTypeConfigDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNotBlank(fileTypeName)) {
			criteria.andFileTypeNameLike(fileTypeName);
		}

		if (StringUtils.isNotBlank(fileExtension)) {
			criteria.andFileExtensionEqualTo(fileExtension);
		}

	}

	public String getFileTypeName() {
		return fileTypeName;
	}

	public void setFileTypeName(String fileTypeName) {
		this.fileTypeName = fileTypeName;
	}

	public String getFileExtension() {
		return fileExtension;
	}

	public void setFileExtension(String fileExtension) {
		this.fileExtension = fileExtension;
	}

}
